﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GoShopping.Model;

namespace GoShopping.BLL.Orders
{
    public class GatheringRecordsBean
    {
        public IList<GatheringRecords> GetAll()
        {
            return Databases.DBGoShoppingOrder.Select(
                GoShoppingOrderNBear.GatheringRecords).ToList<GatheringRecords>();
        }

        public GatheringRecords GetOne(int invoiceID)
        {
            return Databases.DBGoShoppingOrder.Select(
                GoShoppingOrderNBear.GatheringRecords).Where(
                GoShoppingOrderNBear.GatheringRecords.ID == invoiceID).ToSingleObject<GatheringRecords>();
        }

        public GatheringRecords GetByOrderCode(int orderCode)
        {
            return Databases.DBGoShoppingOrder.Select(
                GoShoppingOrderNBear.GatheringRecords).Where(
                GoShoppingOrderNBear.GatheringRecords.OrderID == orderCode).ToSingleObject<GatheringRecords>();
        }

        public int Insert(GatheringRecords invoice)
        {
            return Databases.DBGoShoppingOrder.Insert(
                GoShoppingOrderNBear.GatheringRecords).AddColumn(
                GoShoppingOrderNBear.GatheringRecords.MoneyType, invoice.MoneyType).AddColumn(
                GoShoppingOrderNBear.GatheringRecords.OrderID, invoice.OrderID).AddColumn(
                GoShoppingOrderNBear.GatheringRecords.RecordDate, invoice.RecordDate).AddColumn(
                GoShoppingOrderNBear.GatheringRecords.RecordPerson, invoice.RecordPerson).AddColumn(
                GoShoppingOrderNBear.GatheringRecords.Remark, invoice.Remark).AddColumn(
                GoShoppingOrderNBear.GatheringRecords.Status, invoice.Status).AddColumn(
                GoShoppingOrderNBear.GatheringRecords.TotalPrice, invoice.TotalPrice).AddColumn(
                GoShoppingOrderNBear.GatheringRecords.UserName, invoice.UserName).ExecuteReturnAutoIncrementID(
                GoShoppingOrderNBear.GatheringRecords.ID);
        }
    }
}
